package com.zslc.securitymonitoring.util;

public class DateUtils {


    /**
     * 将double类型的时间点转为时分秒格式
     *
     * @param seconds 秒
     * @return 时分秒
     */
    public static String convertDoubleSecondsToHHMMSS(double seconds) {
        // 获取整数部分作为秒数
        long totalSeconds = (long) seconds;

        // 获取小数部分并转换为毫秒，注意乘以1000并四舍五入以获得更准确的毫秒值
        long milliseconds = Math.round((seconds - totalSeconds) * 1000);

        // 计算小时、分钟和秒
        long hours = totalSeconds / 3600;
        long remainingSecondsAfterHours = totalSeconds % 3600;

        long minutes = remainingSecondsAfterHours / 60;
        long secondsPart = remainingSecondsAfterHours % 60;

        // 格式化输出，前面补零以保持两位数
        return String.format("%02d:%02d:%02d", hours, minutes, secondsPart)
                + (milliseconds > 0 ? "." + String.format("%03d", milliseconds) : "");
    }

}
